#include <string>
#include <sstream>
#include <iostream>

using namespace std;

/*
A A B B C C
    ^i=2
currLen = 1 当前已经统计的字符串长度
*/
string runLengthEncoding(const string &s) {
  int currLen = 1;
  ostringstream oss;

  for (int i = 1; i < s.size(); ++i) {
    // 避免位置 i 越界的情况
    // 比较的时候 s[i-1] 和 s[i]
    if (s[i - 1] == s[i]) {
      currLen += 1;
    }
    else if (s[i - 1] != s[i] || currLen > 9) {
      oss << currLen << s[i - 1];
      currLen = 1;
    }
  }

  return oss.str();
}

int main(int argc, char const *argv[])
{
  /* code */
  return 0;
}
